import java.util.Arrays;

public class Main {
    public static void revers(int[] arr) {
        int i=0,j=arr.length-1;
        while(i<j){
            int tmep=arr[i];
            arr[i]=arr[j];
            arr[j]=tmep;
            i++;
            j--;
        }
    }
    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,4,5};
        revers(arr);
        System.out.println(toString(arr));
    }



    public static String toString(int[] arr){//数组转字符串输出
        String str = "[";
        for (int i = 0; i < arr.length; i++) {
            str+=arr[i];
            if(i!=arr.length-1){
                str+=",";
            }

        }
        str+="]";
        return str;
    }
    public static void main3(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        String ret=toString(arr);
        System.out.println(ret);
    }


    public static void test1(int[] arr){
        arr=new int[]{100,200,300,400,500};//形参指向了新的对象，是不会改变实参的值
    }
    public static void  test2(int[] arr){
        arr[0]=99;//可以改变
    }
    public static void main2(String[] args) {
        int[] arr={1,2,3,4,5};
        test1(arr);
        System.out.println(Arrays.toString(arr));
        test2(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main1(String[] args) {
        int[] arr=new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i]=i;
        }
        String ret=Arrays.toString(arr);
        System.out.println(ret);
    }
}